package com.easylinkin.sm.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import site.morn.data.Displayable;
import site.morn.data.Lockable;
import site.morn.framework.entity.BaseUser;

/**
 * 用户实体类
 *
 * @author TianGanLin
 * @since 1.0.0, 2019/8/13
 */
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@FieldNameConstants
@TableName("sm_user")
@Table(name = "sm_user")
@EqualsAndHashCode(callSuper = true)
public class User extends BaseUser implements Displayable, Lockable {

  /**
   * @serialField
   */
  private static final long serialVersionUID = 1L;

  @ApiModelProperty("显示状态")
  @Column
  private Boolean display;

  @ApiModelProperty("锁定状态")
  @Column
  private Boolean locked;

  @ApiModelProperty("所属角色")
  @ManyToMany
  @ToString.Exclude
  @TableField(exist = false)
  @EqualsAndHashCode.Exclude
  @JoinTable(name = "sm_user_ref_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
  private List<Role> roles;
}
